package Eyjafjalla.power;

import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class SongOfLovePower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:SongOfLovePower";
    private static final PowerStrings powerStrings;

    public SongOfLovePower(AbstractCreature owner,int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        String path128 = "EyjafjallaResources/img/power/SongOfLovePower_84.png";
        String path48 = "EyjafjallaResources/img/power/SongOfLovePower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
        this.enableExtraAmount = true;
        this.amount = amount;
        extraAmount = amount;
        this.updateDescription();
    }

    @Override
    public void stackPower(int stackAmount) {
        extraAmount+=stackAmount;
        super.stackPower(stackAmount);
    }

    @Override
    public void atStartOfTurn() {
        extraAmount = amount;
        updateDescription();
    }

    @Override
    public void onAfterUseCard(AbstractCard card, UseCardAction action) {
        if(extraAmount>0&&card.costForTurn>0&&!card.purgeOnUse&&!card.exhaustOnUseOnce&&!card.exhaust&&!card.exhaustOnFire&&!card.type.equals(AbstractCard.CardType.POWER)){
            extraAmount--;
            this.flash();
            card.setCostForTurn(card.costForTurn-1);
            card.shuffleBackIntoDrawPile = false;
            card.returnToHand = true;
            updateDescription();
        }
        else {
            card.returnToHand = false;
        }
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0]+amount+powerStrings.DESCRIPTIONS[1]+extraAmount+powerStrings.DESCRIPTIONS[2];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}




